import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
const router = new Router({
  routes: [
    {
      path: '/',
      redirect: '/login/'
    },
    {
      path: '/noLogin',
      name: 'noLogin',
      meta: {
        background: 'bgy-login-bg',
        login: true
      },
      component: resolve => require(['@/views/noLogin.vue'], resolve)
    },
    {
      path: '/login',
      name: 'login',
      meta: {
        background: 'bgy-login-bg',
        login: true
      },
      component: resolve => require(['@/views/login.vue'], resolve)
    },
    {
      path: '/projectLogin',
      name: 'projectLogin',
      meta: {
        background: 'bgy-project-bg',
        login: true
      },
      component: resolve => require(['@/views/projectLogin.vue'], resolve)
    },
    {
      path: '/ticket',
      name: 'ticket',
      meta: {
        background: 'bgy-screen-video',
        login: true
      },
      component: resolve => require(['@/views/ticket.vue'], resolve)
    },
    {
      path: 'screen',
      meta: {
        background: 'bgy-login-bg'
      },
      component: resolve => require(['@/views/screen/index.vue'], resolve),
      children: [
        {
          path: '/project',
          name: 'projectVideo',
          meta: {
            background: 'bgy-screen-video',
            keepAlive: true,
            loginType: 'projectLogin',
            stageId: true // 需要先获取分期Id
          },
          component: resolve => require(['@/views/screen/project/home.vue'], resolve)
        },
        {
          path: '/video',
          name: 'video',
          redirect: { name: 'videoArea' },
          component: resolve => require(['@/views/screen/video/index.vue'], resolve),
          children: [
            // 视频监控企业版
            {
              path: 'area',
              name: 'videoArea',
              meta: {
                background: 'bgy-screen-video',
                loginType: 'login',
                keepAlive: true
              },
              component: resolve => require(['@/views/screen/video/area.vue'], resolve)
            },
            // 企业大屏视频监控
            {
              path: 'screen/area',
              name: 'screenVideoArea',
              meta: {
                background: 'bgy-screen-video',
                loginType: 'loginCompany',
                keepAlive: true
              },
              component: resolve => require(['@/views/screen/video/area.vue'], resolve)
            },
            // 视频监控系统的页面
            {
              path: 'project',
              name: 'videoProject',
              meta: {
                background: 'bgy-screen-video',
                loginType: 'login',
                keepAlive: true
              },
              component: resolve => require(['@/views/screen/video/project.vue'], resolve)
            },
            // 项目大屏的视频监控
            {
              path: 'screen/project',
              name: 'screenVideoProject',
              meta: {
                background: 'bgy-screen-video',
                loginType: 'projectLogin',
                keepAlive: true,
                stageId: true
              },
              component: resolve => require(['@/views/screen/video/project.vue'], resolve)
            },
            // 视频监控云控制台
            {
              path: 'control',
              name: 'videoControl',
              meta: {
                background: 'bgy-screen-video',
                loginType: 'login',
                keepAlive: true
              },
              component: resolve => require(['@/views/screen/video/control.vue'], resolve)
            },
            // 项目大屏云控制台
            {
              path: 'screen/control',
              name: 'screenVideoControl',
              meta: {
                background: 'bgy-screen-video',
                loginType: 'projectLogin',
                keepAlive: true
              },
              component: resolve => require(['@/views/screen/video/control.vue'], resolve)
            },
            // 企业大屏云控制台
            {
              path: 'company/control',
              name: 'companyVideoControl',
              meta: {
                background: 'bgy-screen-video',
                loginType: 'loginCompany',
                keepAlive: true
              },
              component: resolve => require(['@/views/screen/video/control.vue'], resolve)
            }
          ]
        },
        {
          path: '/panoramagram',
          name: 'panoramagram',
          meta: {
            background: 'bgy-screen-video',
            keepAlive: true,
            loginType: 'projectLogin',
            stageId: true
          },
          component: resolve => require(['@/views/screen/panoramagram/index.vue'], resolve)
        },
        {
          path: '/panoramagramPreview',
          name: 'panoramagramPreview',
          meta: {
            background: 'bgy-screen-video',
            keepAlive: true,
            stageId: true
          },
          component: resolve => require(['@/views/screen/panoramagram/index.vue'], resolve)
        },
        {
          path: '/company',
          name: 'company',
          meta: {
            background: 'bgy-screen-video'
          },
          component: resolve => require(['@/views/screen/company/home.vue'], resolve)
        }
      ]
    },
    {
      path: '/map',
      name: 'videoMap',
      meta: {
        background: 'bgy-screen-video'
      },
      component: resolve => require(['@/views/screen/video/map/map.vue'], resolve)
    },
    {
      path: '/AIvideo',
      name: 'AIvideo',
      meta: {
        background: 'bgy-screen-video',
        keepAlive: true
      },
      component: resolve => require(['@/views/screen/video/AIvideo/AIvideo.vue'], resolve)
    },
    {
      path: '/picture',
      name: 'picture',
      meta: {
        background: 'bgy-screen-video'
      },
      redirect: { name: 'pictures' },
      component: resolve => require(['@/views/screen/video/picture/index.vue'], resolve),
      children: [
        // 图片集管理
        {
          path: 'pictures',
          name: 'pictures',
          meta: {
            loginType: 'login',
            showBack: true,
            background: 'bgy-screen-video'
          },
          component: resolve => require(['@/views/screen/video/picture/picture.vue'], resolve)
        },
        // 图片集某天详情管理
        {
          path: 'picture/detail',
          name: 'pictureDetail',
          meta: {
            loginType: 'login',
            background: 'bgy-screen-video'
          },
          component: resolve => require(['@/views/screen/video/picture/detail.vue'], resolve)
        }
      ]
    }
  ]
})
router.beforeEach((to, from, next) => {
  window.document.body.className = to.meta.background
  next()
})
export default router

